//
// Created by Administrator on 2020/10/21.
//

#ifndef O5G_SRC_CCORE_PHY_RF_INCLUDE_RFDEF_H_
#define O5G_SRC_CCORE_PHY_RF_INCLUDE_RFDEF_H_

#include "../../../include/commDef.h"


#define RF_PARAM_LEN (256)

#define O5G_RF_CARRIER_NUM_MAX 4
#define O5G_RF_PORT_NUM_MAX    4
#define O5G_RF_CHANNEL_NUM_MAX (O5G_RF_CARRIER_NUM_MAX * O5G_RF_PORT_NUM_MAX)

typedef _Complex float cfloat_t;

typedef struct
{
    void* handler;
    void* dev;

    // The following variables are for threaded RX gain control
    int8_t thread_gain_run;
    pthread_t thread_gain;
    pthread_cond_t cond;
    pthread_mutex_t mutex;
    double cur_rx_gain;
    double new_rx_gain;
    int8_t tx_gain_same_rx;
    float tx_rx_gain_offset;
} rf_t;

typedef struct
{
    double min_tx_gain;
    double max_tx_gain;
    double min_rx_gain;
    double max_rx_gain;
} rf_info_t;

typedef struct
{
    enum
    {
        RF_ERROR_LATE,
        RF_ERROR_UNDERFLOW,
        RF_ERROR_OVERFLOW,
        RF_ERROR_RX,
        RF_ERROR_OTHER
    } type;
    int opt;
    const char* msg;
} rf_error_t;

typedef void (* rf_error_handler_t)(void* arg, rf_error_t error);

#endif //O5G_SRC_CCORE_PHY_RF_INCLUDE_RFDEF_H_
